{% extends "base.html" %}

{% block title %}借阅申请管理{% endblock %}

{% block content %}
<div class="container mt-4">
    <h2>待处理借阅申请</h2>
    <div class="table-responsive">
        <table class="table table-hover">
            <thead class="table-light">
                <tr>
                    <th>申请人</th>
                    <th>图书</th>
                    <th>申请时间</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {% for request in requests %}
                <tr>
                    <td>{{ request.requester.username }}</td>
                    <td>{{ request.book.title }} ({{ request.book.author }})</td>
                    <td>{{ request.request_time.strftime('%Y-%m-%d %H:%M') }}</td>
                    <td>
                        <span class="badge bg-{% if request.status == 'pending' %}warning{% else %}success{% endif %}">
                            {{ request.status }}
                        </span>
                    </td>
                    <td>
                        {% if request.status == 'pending' %}
                        <form action="{{ url_for('admin.approve_borrow', request_id=request.id) }}" method="post" class="d-inline">
                            <button type="submit" class="btn btn-sm btn-success">批准</button>
                        </form>
                        <form action="{{ url_for('admin.reject_borrow', request_id=request.id) }}" method="post" class="d-inline">
                            <button type="submit" class="btn btn-sm btn-danger">拒绝</button>
                        </form>
                        {% endif %}
                    </td>
                </tr>
                {% else %}
                <tr>
                    <td colspan="5" class="text-center text-muted">暂无待处理的借阅申请</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endblock %}
